package com.heima.admin.controller.v1;

import com.heima.admin.service.AdChannelService;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.AdWmChannelDto;
import com.heima.model.wemedia.dtos.WmChannelDto;
import com.heima.model.wemedia.pojos.WmChannel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/channel")
public class AdChannelController {

    /**
     * 模糊查询频道列表
     * @param dto 频道dto
     * @return
     */
    @Autowired
    private AdChannelService adChannelService;
    @PostMapping("/list")
    public ResponseResult list(@RequestBody AdWmChannelDto dto){
        return adChannelService.list(dto);
    }

    @PostMapping("/save")
    public ResponseResult saveChannel(@RequestBody WmChannelDto channel){
        return adChannelService.saveChannel(channel);
    }
    @PostMapping("/update")
    public ResponseResult updateChannel(@RequestBody WmChannelDto channel){
        return adChannelService.updateChannel(channel);
    }

    /**
     * 删除频道，有引用的频道不能进行删除
     * @param id
     * @return
     */
    @GetMapping("/del/{id}")
    public ResponseResult delChannel(@PathVariable Integer id){
        return adChannelService.delChannel(id);
    }


}
